using UnityEngine;
namespace CGF
{
    public partial class PanelWebView : UIComponentBase, IAwake<UILayer, bool>, IDestroy
    {
        public static void Open(string url)
        {
            UIManagerComponent.instance.OpenUI<PanelWebView>(UILayer.Normal, RootComponent.instance, false).SetURL(url);
        }

        public static void Close()
        {
            UIManagerComponent.instance.CloseUI<PanelWebView>();
        }

        public async void Awake(UILayer layer, bool isFloat)
        {
            await SpawnPrefab("Prefabs/GameUI/PanelWebView", layer, isFloat);
			BindProperties(transform);
            
            BtnBack.SetClick(Close);
        }

        private void SetURL(string url)
        {
            WebViewHelper.CreateWebView(url, Holder).Invoke();
        }

        public override void OnDestroy()
        {
            base.OnDestroy();
        }

    }
}
